<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

use Illuminate\Support\Facades\Storage;

Route::get('/', 'HomeController@index');

Route::view('/photos','frontend.photos');

Route::get('/videos','HomeController@videos');

Route::view('/contact','frontend.contact');

Route::get('/photo/{type}','HomeController@photo');

Route::get('/testimonials','HomeController@showTestimonials');

Route::post('/testimonials','HomeController@testimonials');

Route::post('/contact','HomeController@contact');

Route::get('storage/{one?}/{two?}/{three?}/{filename}', function ($filename)
{
    $realpath = str_replace('storage/','',Request::path());

    $path = storage_path('app/') . $realpath;

    if(Storage::exists($path)){
        return response('',404);
    }

    return Image::make($path)->response();

//    if(!file_exists($path)){
//        //报404错误
//        header("HTTP/1.1 404 Not Found");
//        header("Status: 404 Not Found");
//        exit;
//    }
//    //输出图片
//    header('Content-type: image/jpg');
//    echo file_get_contents($path);
//    exit;

});
